package com.ctshk.rpc.air.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ctshk.common.enums.AirProductChannelType;
import com.ctshk.rpc.air.dto.AirProductSaleStrategyPriceDTO;
import com.ctshk.rpc.air.dto.AirProductSaleStrategyPriceDateDTO;
import com.ctshk.rpc.air.entity.*;
import com.ctshk.rpc.air.mapper.*;
import com.ctshk.rpc.air.req.AirProductSaleStrategyPriceReq;
import com.ctshk.rpc.air.service.IAirProductSaleStrategyService;
import com.ctshk.rpc.system.service.ISysDepartmentService;
import com.github.houbb.heaven.util.util.CollectionUtil;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.google.common.collect.Sets;
import org.apache.dubbo.config.annotation.DubboReference;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.beans.factory.annotation.Autowired;

import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import java.time.temporal.ChronoUnit;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;
import java.util.stream.Stream;

/**
 * <p>
 * 机票销售加幅策略 服务实现类
 * </p>
 *
 * @author lihang
 * @since 2021-03-09
 */
@DubboService
public class AirProductSaleStrategyServiceImpl extends ServiceImpl<AirProductSaleStrategyMapper, AirProductSaleStrategy> implements IAirProductSaleStrategyService {

    @Autowired
    private AirProductSaleStrategyMapper airProductSaleStrategyMapper;

    @Autowired
    private AirProductSaleStrategyVaildDateMapper airProductSaleStrategyVaildDateMapper;

    @Autowired
    private AirProductChannelOfflineMapper airProductChannelOfflineMapper;

    @Autowired
    private AirProductChannelOfflineAgentCustomMapper airProductChannelOfflineAgentCustomMapper;

    @Autowired
    private AirProductChannelOfflineSelfCustomMapper airProductChannelOfflineSelfCustomMapper;

    @Autowired
    private AirProductChannelOnlineSelfPlatformMapper airProductChannelOnlineSelfPlatformMapper;

    @Autowired
    private AirProductChannelOnlineThirdPlatformMapper airProductChannelOnlineThirdPlatformMapper;

    @DubboReference
    private ISysDepartmentService iSysDepartmentService;

    @Override
    public List<AirProductSaleStrategyPriceDTO> queryProductStrategy(AirProductSaleStrategyPriceReq req) {
        List<Long> productIds = req.getProductIds();
        List<AirProductSaleStrategyPriceDTO> airProductSaleStrategyPriceDTOList = Lists.newArrayList();
        QueryWrapper<AirProductSaleStrategy> saleStrategyQueryWrapper = new QueryWrapper<>();
        /**获取进行加幅的时间段*/
        LocalDate starDate = req.getStarDate();
        LocalDate endDate = req.getEndDate().plusDays(1);
        List<LocalDate> saleStrategyPriceDates = Stream.iterate(starDate, date -> date.plusDays(1))
                .limit(ChronoUnit.DAYS.between(starDate, endDate))
                .collect(Collectors.toList());
        AirProductChannelType airProductChannelType = AirProductChannelType.get(req.getChannelType());
        for (Long productId : productIds) {
            AirProductSaleStrategyPriceDTO airProductSaleStrategyPriceDTO = new AirProductSaleStrategyPriceDTO();
            airProductSaleStrategyPriceDTO.setProductId(productId);
            airProductSaleStrategyPriceDTO.setChannelType(req.getChannelType());
            airProductSaleStrategyPriceDTO.setRelationId(req.getRelationId());
            saleStrategyQueryWrapper.clear();
            saleStrategyQueryWrapper.lambda().eq(AirProductSaleStrategy::getProductId, productId);
            List<AirProductSaleStrategy> airProductSaleStrategyList = airProductSaleStrategyMapper.selectList(saleStrategyQueryWrapper);
            if (CollectionUtil.isEmpty(airProductSaleStrategyList)) {
                airProductSaleStrategyPriceDTO.setForbidTheSale(true);
                airProductSaleStrategyPriceDTOList.add(airProductSaleStrategyPriceDTO);
                continue;
            }
            Set<Long> strategyIdSets = Sets.newHashSet();
            for (AirProductSaleStrategy strategy : airProductSaleStrategyList) {
                strategyIdSets.add(strategy.getId());
            }
            /**查询策略有效期*/
            QueryWrapper<AirProductSaleStrategyVaildDate> saleStrategyVaildDateQueryWrapper = new QueryWrapper<>();
            saleStrategyVaildDateQueryWrapper.lambda().in(AirProductSaleStrategyVaildDate::getStrategyId, strategyIdSets);
            List<AirProductSaleStrategyVaildDate> saleStrategyVaildDates = airProductSaleStrategyVaildDateMapper.selectList(saleStrategyVaildDateQueryWrapper);
            Set<LocalDate> localDateSet = Sets.newHashSet();
            Map<LocalDate, Long> dateStrategyIdMap = Maps.newHashMap();
            for (AirProductSaleStrategyVaildDate saleStrategyVaildDate : saleStrategyVaildDates) {
                LocalDate dateBegin = saleStrategyVaildDate.getTimeBegin();
                LocalDate dateEnd = saleStrategyVaildDate.getTimeEnd();
                List<LocalDate> costDateBt = Stream.iterate(dateBegin, date -> date.plusDays(1))
                        .limit(ChronoUnit.DAYS.between(dateBegin, dateEnd))
                        .collect(Collectors.toList());
                localDateSet.addAll(costDateBt);
                for (LocalDate localDate : costDateBt) {
                    dateStrategyIdMap.put(localDate, saleStrategyVaildDate.getStrategyId());
                }
            }
            /**判断是否包含所有需要加幅的日期*/
            boolean isContDate = false;
            for (LocalDate saleStrategyPriceDate : saleStrategyPriceDates) {
                if (!localDateSet.contains(saleStrategyPriceDate)) {
                    isContDate = true;
                    break;
                }
            }
            if (isContDate) {
                airProductSaleStrategyPriceDTO.setForbidTheSale(true);
                airProductSaleStrategyPriceDTOList.add(airProductSaleStrategyPriceDTO);
                continue;
            }
            List<AirProductSaleStrategyPriceDateDTO> airProductSaleStrategyPriceDateDTOList = Lists.newArrayList();
            Map<Long, List<LocalDate>> strategyDateMap = Maps.newHashMap();
            for (LocalDate saleStrategyPriceDate : saleStrategyPriceDates) {
                Long strategyId = dateStrategyIdMap.get(saleStrategyPriceDate);
                List<LocalDate> mapValue = strategyDateMap.get(strategyId);
                if (null == mapValue) {
                    mapValue = Lists.newArrayList();
                }
                mapValue.add(saleStrategyPriceDate);
                strategyDateMap.put(strategyId, mapValue);
            }
            boolean forbidTheSale = false;
            switch (airProductChannelType) {
                case SELF_CUSTTOM:
                    for (Map.Entry<Long, List<LocalDate>> entry : strategyDateMap.entrySet()) {
                        List<AirProductSaleStrategyPriceDateDTO> result = selfCusTTom(entry.getKey(), entry.getValue(), req.getRelationId());
                        if (CollectionUtil.isEmpty(result)) {
                            forbidTheSale = true;
                            break;
                        } else {
                            airProductSaleStrategyPriceDateDTOList.addAll(result);
                        }
                    }
                    if (forbidTheSale) {
                        airProductSaleStrategyPriceDTO.setForbidTheSale(true);
                        airProductSaleStrategyPriceDTO.setAirProductSaleStrategyPriceDateDTOList(null);
                        airProductSaleStrategyPriceDTOList.add(airProductSaleStrategyPriceDTO);
                    } else {
                        airProductSaleStrategyPriceDTO.setAirProductSaleStrategyPriceDateDTOList(airProductSaleStrategyPriceDateDTOList);
                        airProductSaleStrategyPriceDTOList.add(airProductSaleStrategyPriceDTO);
                    }
                    break;
                case AGENT_CUSTTOM:
                    for (Map.Entry<Long, List<LocalDate>> entry : strategyDateMap.entrySet()) {
                        List<AirProductSaleStrategyPriceDateDTO> result = selfAgent(entry.getKey(), entry.getValue(), req.getRelationId());
                        if (CollectionUtil.isEmpty(result)) {
                            forbidTheSale = true;
                            break;
                        } else {
                            airProductSaleStrategyPriceDateDTOList.addAll(result);
                        }
                    }
                    if (forbidTheSale) {
                        airProductSaleStrategyPriceDTO.setForbidTheSale(true);
                        airProductSaleStrategyPriceDTO.setAirProductSaleStrategyPriceDateDTOList(null);
                        airProductSaleStrategyPriceDTOList.add(airProductSaleStrategyPriceDTO);
                    } else {
                        airProductSaleStrategyPriceDTO.setAirProductSaleStrategyPriceDateDTOList(airProductSaleStrategyPriceDateDTOList);
                        airProductSaleStrategyPriceDTOList.add(airProductSaleStrategyPriceDTO);
                    }
                    break;
                case SELF_PLATFROM:
                    for (Map.Entry<Long, List<LocalDate>> entry : strategyDateMap.entrySet()) {
                        List<AirProductSaleStrategyPriceDateDTO> result = selfOnLine(entry.getKey(), entry.getValue(), req.getRelationId());
                        if (CollectionUtil.isEmpty(result)) {
                            forbidTheSale = true;
                            break;
                        } else {
                            airProductSaleStrategyPriceDateDTOList.addAll(result);
                        }
                    }
                    if (forbidTheSale) {
                        airProductSaleStrategyPriceDTO.setForbidTheSale(true);
                        airProductSaleStrategyPriceDTO.setAirProductSaleStrategyPriceDateDTOList(null);
                        airProductSaleStrategyPriceDTOList.add(airProductSaleStrategyPriceDTO);
                    } else {
                        airProductSaleStrategyPriceDTO.setAirProductSaleStrategyPriceDateDTOList(airProductSaleStrategyPriceDateDTOList);
                        airProductSaleStrategyPriceDTOList.add(airProductSaleStrategyPriceDTO);
                    }
                    break;
                default:
                    airProductSaleStrategyPriceDTO.setForbidTheSale(true);
                    airProductSaleStrategyPriceDTOList.add(airProductSaleStrategyPriceDTO);
                    break;
            }
        }
        return airProductSaleStrategyPriceDTOList;
    }


    /**
     * 组装 线下  自营上架策略价格加幅信息  返回为空 为禁售
     *
     * @param strategyId
     * @param saleStrategyPriceDates
     * @param relationId
     * @return
     */
    private List<AirProductSaleStrategyPriceDateDTO> selfCusTTom(Long strategyId, List<LocalDate> saleStrategyPriceDates, Long relationId) {
        List<AirProductSaleStrategyPriceDateDTO> airProductSaleStrategyPriceDateDTOList = Lists.newArrayList();
        QueryWrapper<AirProductChannelOffline> productChannelOfflineQueryWrapper = new QueryWrapper<>();
        productChannelOfflineQueryWrapper.lambda().eq(AirProductChannelOffline::getStrategyId, strategyId);
        productChannelOfflineQueryWrapper.lambda().eq(AirProductChannelOffline::getChannelType, 1);
        AirProductChannelOffline airProductChannelOffline = airProductChannelOfflineMapper.selectOne(productChannelOfflineQueryWrapper);
        QueryWrapper<AirProductChannelOfflineSelfCustom> airProductChannelOfflineSelfCustomQueryWrapper = new QueryWrapper<>();
        if (airProductChannelOffline.getVisableType().intValue() == 1) {//表示禁售
            return Lists.newArrayList();
        } else if (airProductChannelOffline.getVisableType().intValue() == 2) {//
            airProductChannelOfflineSelfCustomQueryWrapper.clear();
            airProductChannelOfflineSelfCustomQueryWrapper.lambda().eq(AirProductChannelOfflineSelfCustom::getOfflineId, airProductChannelOffline.getId());
            AirProductChannelOfflineSelfCustom productChannelOfflineSelfCustom = airProductChannelOfflineSelfCustomMapper.selectOne(airProductChannelOfflineSelfCustomQueryWrapper);
            if (null == productChannelOfflineSelfCustom) {
                return Lists.newArrayList();
            } else {
                /**组装加幅信息*/
                for (LocalDate saleStrategyPriceDate : saleStrategyPriceDates) {
                    AirProductSaleStrategyPriceDateDTO airProductSaleStrategyPriceDateDTO = new AirProductSaleStrategyPriceDateDTO();
                    airProductSaleStrategyPriceDateDTO.setDate(saleStrategyPriceDate);
                    airProductSaleStrategyPriceDateDTO.setAdjustType(productChannelOfflineSelfCustom.getAdjustType());
                    airProductSaleStrategyPriceDateDTO.setIsLimit(productChannelOfflineSelfCustom.getIsLimit());
                    airProductSaleStrategyPriceDateDTO.setLimitNum(productChannelOfflineSelfCustom.getLimitNum());
                    if (productChannelOfflineSelfCustom.getAdjustType().intValue() == 1) {
                        airProductSaleStrategyPriceDateDTO.setValue(productChannelOfflineSelfCustom.getAmount().doubleValue());
                    } else {
                        airProductSaleStrategyPriceDateDTO.setValue(productChannelOfflineSelfCustom.getPercent());
                    }
                    airProductSaleStrategyPriceDateDTOList.add(airProductSaleStrategyPriceDateDTO);
                }
                return airProductSaleStrategyPriceDateDTOList;
            }
        } else if (airProductChannelOffline.getVisableType().intValue() == 3) {
            /**首先匹配用 用户没匹配上 则匹配部门信息*/
            airProductChannelOfflineSelfCustomQueryWrapper.clear();
            airProductChannelOfflineSelfCustomQueryWrapper.lambda().eq(AirProductChannelOfflineSelfCustom::getOfflineId, airProductChannelOffline.getId());
            airProductChannelOfflineSelfCustomQueryWrapper.lambda().eq(AirProductChannelOfflineSelfCustom::getCheckType, 2);
            airProductChannelOfflineSelfCustomQueryWrapper.lambda().eq(AirProductChannelOfflineSelfCustom::getRelationId, relationId);
            AirProductChannelOfflineSelfCustom productChannelOfflineSelfCustom = airProductChannelOfflineSelfCustomMapper.selectOne(airProductChannelOfflineSelfCustomQueryWrapper);
            if (null != productChannelOfflineSelfCustom) {
                /**组装加幅信息*/
                for (LocalDate saleStrategyPriceDate : saleStrategyPriceDates) {
                    AirProductSaleStrategyPriceDateDTO airProductSaleStrategyPriceDateDTO = new AirProductSaleStrategyPriceDateDTO();
                    airProductSaleStrategyPriceDateDTO.setDate(saleStrategyPriceDate);
                    airProductSaleStrategyPriceDateDTO.setAdjustType(productChannelOfflineSelfCustom.getAdjustType());
                    if (productChannelOfflineSelfCustom.getAdjustType().intValue() == 1) {
                        airProductSaleStrategyPriceDateDTO.setValue(productChannelOfflineSelfCustom.getAmount().doubleValue());
                    } else {
                        airProductSaleStrategyPriceDateDTO.setValue(productChannelOfflineSelfCustom.getPercent());
                    }
                    airProductSaleStrategyPriceDateDTO.setIsLimit(productChannelOfflineSelfCustom.getIsLimit());
                    airProductSaleStrategyPriceDateDTO.setLimitNum(productChannelOfflineSelfCustom.getLimitNum());
                    airProductSaleStrategyPriceDateDTOList.add(airProductSaleStrategyPriceDateDTO);
                }
                return airProductSaleStrategyPriceDateDTOList;
            } else {//匹配部门
                airProductChannelOfflineSelfCustomQueryWrapper.clear();
                airProductChannelOfflineSelfCustomQueryWrapper.lambda().eq(AirProductChannelOfflineSelfCustom::getOfflineId, airProductChannelOffline.getId());
                airProductChannelOfflineSelfCustomQueryWrapper.lambda().eq(AirProductChannelOfflineSelfCustom::getCheckType, 1);
                List<AirProductChannelOfflineSelfCustom> productChannelOfflineSelfCustomList =
                        airProductChannelOfflineSelfCustomMapper.selectList(airProductChannelOfflineSelfCustomQueryWrapper);
                boolean isExit = false;
                for (AirProductChannelOfflineSelfCustom airProductChannelOfflineSelfCustom : productChannelOfflineSelfCustomList) {
                    isExit = iSysDepartmentService.isExist(airProductChannelOfflineSelfCustom.getRelationId(), relationId);
                    if (isExit) {
                        /**组装加幅信息*/
                        for (LocalDate saleStrategyPriceDate : saleStrategyPriceDates) {
                            AirProductSaleStrategyPriceDateDTO airProductSaleStrategyPriceDateDTO = new AirProductSaleStrategyPriceDateDTO();
                            airProductSaleStrategyPriceDateDTO.setDate(saleStrategyPriceDate);
                            airProductSaleStrategyPriceDateDTO.setAdjustType(airProductChannelOfflineSelfCustom.getAdjustType());
                            airProductSaleStrategyPriceDateDTO.setIsLimit(airProductChannelOfflineSelfCustom.getIsLimit());
                            airProductSaleStrategyPriceDateDTO.setLimitNum(airProductChannelOfflineSelfCustom.getLimitNum());
                            if (airProductChannelOfflineSelfCustom.getAdjustType().intValue() == 1) {
                                airProductSaleStrategyPriceDateDTO.setValue(airProductChannelOfflineSelfCustom.getAmount().doubleValue());
                            } else {
                                airProductSaleStrategyPriceDateDTO.setValue(airProductChannelOfflineSelfCustom.getPercent());
                            }
                            airProductSaleStrategyPriceDateDTOList.add(airProductSaleStrategyPriceDateDTO);
                        }
                        break;
                    }
                }
                if (!isExit) {
                    return Lists.newArrayList();
                } else {
                    return airProductSaleStrategyPriceDateDTOList;
                }
            }
        } else {
            return Lists.newArrayList();
        }
    }

    /**
     * 组装 线下  代理商 上架策略价格加幅信息  返回为空 为禁售
     *
     * @param strategyId
     * @param saleStrategyPriceDates
     * @param relationId
     * @return
     */
    private List<AirProductSaleStrategyPriceDateDTO> selfAgent(Long strategyId, List<LocalDate> saleStrategyPriceDates, Long relationId) {
        List<AirProductSaleStrategyPriceDateDTO> airProductSaleStrategyPriceDateDTOList = Lists.newArrayList();
        QueryWrapper<AirProductChannelOffline> productChannelOfflineQueryWrapper = new QueryWrapper<>();
        productChannelOfflineQueryWrapper.lambda().eq(AirProductChannelOffline::getStrategyId, strategyId);
        productChannelOfflineQueryWrapper.lambda().eq(AirProductChannelOffline::getChannelType, 2);
        AirProductChannelOffline airProductChannelOfflineAgent = airProductChannelOfflineMapper.selectOne(productChannelOfflineQueryWrapper);
        QueryWrapper<AirProductChannelOfflineAgentCustom> airProductChannelOfflineAgentCustomQueryWrapper = new QueryWrapper<>();
        if (airProductChannelOfflineAgent.getVisableType().intValue() == 1) {
            return Lists.newArrayList();
        } else if (airProductChannelOfflineAgent.getVisableType().intValue() == 2) {
            airProductChannelOfflineAgentCustomQueryWrapper.clear();
            airProductChannelOfflineAgentCustomQueryWrapper.lambda().eq(AirProductChannelOfflineAgentCustom::getOfflineId, airProductChannelOfflineAgent.getId());
            AirProductChannelOfflineAgentCustom productChannelOfflineAgentCustom =
                    airProductChannelOfflineAgentCustomMapper.selectOne(airProductChannelOfflineAgentCustomQueryWrapper);
            if (null == productChannelOfflineAgentCustom) {
                return Lists.newArrayList();
            } else {
                /**组装加幅信息*/
                for (LocalDate saleStrategyPriceDate : saleStrategyPriceDates) {
                    AirProductSaleStrategyPriceDateDTO airProductSaleStrategyPriceDateDTO = new AirProductSaleStrategyPriceDateDTO();
                    airProductSaleStrategyPriceDateDTO.setDate(saleStrategyPriceDate);
                    airProductSaleStrategyPriceDateDTO.setAdjustType(productChannelOfflineAgentCustom.getAdjustType());
                    if (productChannelOfflineAgentCustom.getAdjustType().intValue() == 1) {
                        airProductSaleStrategyPriceDateDTO.setValue(productChannelOfflineAgentCustom.getAmount().doubleValue());
                    } else {
                        airProductSaleStrategyPriceDateDTO.setValue(productChannelOfflineAgentCustom.getPercent());
                    }
                    airProductSaleStrategyPriceDateDTO.setIsLimit(productChannelOfflineAgentCustom.getIsLimit());
                    airProductSaleStrategyPriceDateDTO.setLimitNum(productChannelOfflineAgentCustom.getLimitNum());
                    airProductSaleStrategyPriceDateDTOList.add(airProductSaleStrategyPriceDateDTO);
                }
                return airProductSaleStrategyPriceDateDTOList;
            }
        } else if (airProductChannelOfflineAgent.getVisableType().intValue() == 3) {
            airProductChannelOfflineAgentCustomQueryWrapper.clear();
            airProductChannelOfflineAgentCustomQueryWrapper.lambda().eq(AirProductChannelOfflineAgentCustom::getOfflineId, airProductChannelOfflineAgent.getId());
            airProductChannelOfflineAgentCustomQueryWrapper.lambda().eq(AirProductChannelOfflineAgentCustom::getAgentId, relationId);
            AirProductChannelOfflineAgentCustom productChannelOfflineAgentCustom =
                    airProductChannelOfflineAgentCustomMapper.selectOne(airProductChannelOfflineAgentCustomQueryWrapper);
            /**组装加幅信息*/
            for (LocalDate saleStrategyPriceDate : saleStrategyPriceDates) {
                AirProductSaleStrategyPriceDateDTO airProductSaleStrategyPriceDateDTO = new AirProductSaleStrategyPriceDateDTO();
                airProductSaleStrategyPriceDateDTO.setDate(saleStrategyPriceDate);
                airProductSaleStrategyPriceDateDTO.setAdjustType(productChannelOfflineAgentCustom.getAdjustType());
                if (productChannelOfflineAgentCustom.getAdjustType().intValue() == 1) {
                    airProductSaleStrategyPriceDateDTO.setValue(productChannelOfflineAgentCustom.getAmount().doubleValue());
                } else {
                    airProductSaleStrategyPriceDateDTO.setValue(productChannelOfflineAgentCustom.getPercent());
                }
                airProductSaleStrategyPriceDateDTO.setIsLimit(productChannelOfflineAgentCustom.getIsLimit());
                airProductSaleStrategyPriceDateDTO.setLimitNum(productChannelOfflineAgentCustom.getLimitNum());
                airProductSaleStrategyPriceDateDTOList.add(airProductSaleStrategyPriceDateDTO);
            }
            return airProductSaleStrategyPriceDateDTOList;
        } else {
            return Lists.newArrayList();
        }
    }

    /**
     * 组装 线上   上架策略价格加幅信息  返回为空 为禁售
     *
     * @param strategyId
     * @param saleStrategyPriceDates
     * @param channelId
     * @return
     */
    private List<AirProductSaleStrategyPriceDateDTO> selfOnLine(Long strategyId, List<LocalDate> saleStrategyPriceDates, Long channelId) {
        List<AirProductSaleStrategyPriceDateDTO> airProductSaleStrategyPriceDateDTOList = Lists.newArrayList();
        QueryWrapper<AirProductChannelOnlineSelfPlatform> airProductChannelOfflineAgentCustomQueryWrapper = new QueryWrapper<>();
        airProductChannelOfflineAgentCustomQueryWrapper.lambda()
                .eq(AirProductChannelOnlineSelfPlatform::getStrategyId, strategyId)
                .eq(AirProductChannelOnlineSelfPlatform::getChannelId,1364862312965656577L)
        ;
        LocalDate.now().format(DateTimeFormatter.ofPattern("yyyy"));
        AirProductChannelOnlineSelfPlatform productChannelOfflineAgentCustom = airProductChannelOnlineSelfPlatformMapper.selectOne(airProductChannelOfflineAgentCustomQueryWrapper);
        if (null == productChannelOfflineAgentCustom) {
            return Lists.newArrayList();
        } else {
            /**组装加幅信息*/
            for (LocalDate saleStrategyPriceDate : saleStrategyPriceDates) {
                AirProductSaleStrategyPriceDateDTO airProductSaleStrategyPriceDateDTO = new AirProductSaleStrategyPriceDateDTO();
                airProductSaleStrategyPriceDateDTO.setDate(saleStrategyPriceDate);
                airProductSaleStrategyPriceDateDTO.setAdjustType(productChannelOfflineAgentCustom.getAdjustType());
                if (productChannelOfflineAgentCustom.getAdjustType().intValue() == 1) {
                    airProductSaleStrategyPriceDateDTO.setValue(productChannelOfflineAgentCustom.getAmount().doubleValue());
                } else {
                    airProductSaleStrategyPriceDateDTO.setValue(productChannelOfflineAgentCustom.getPercent());
                }
                airProductSaleStrategyPriceDateDTO.setIsLimit(productChannelOfflineAgentCustom.getIsLimit());
                airProductSaleStrategyPriceDateDTO.setLimitNum(productChannelOfflineAgentCustom.getLimitNum());
                airProductSaleStrategyPriceDateDTOList.add(airProductSaleStrategyPriceDateDTO);
            }
            return airProductSaleStrategyPriceDateDTOList;
        }
    }
}
